<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>邮箱</title>
</head>
<body>
<%-- 	${param.email1}<br/>				<!-- 读取model存的值 --> --%>
		我们已向您的邮箱发送一条验证码，请注意查收：<br/>
		<form action="/checkEmailCode" method="post" id = "reg_form0">
		<input id="emailCode" type="hidden" name="emailCode" maxlength="200" value ="${param.emailCode1}"/>	
		</form>
	<form action="/emails" method="post" id = "reg_form">
	<input id="username" type="hidden" name="username" maxlength="200" value ="${param.username1}"/>
	<input id="email" type="hidden" name="email" maxlength="200" value ="${param.email1}"/>	
	
	验证码：<input id="code" type="text" placeholder="请输入验证码" name="code" maxlength="200" />
               
    <input type="button" value="找回" onclick="checkCode()"/> 
     	<span id="span1"></span><br/> 
    </form>
    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
	<script type="text/javascript">
	$(function() {
		
		submitForm();
	})
	
	function checkCode(){
 		var code = $('#code').val();
 		$.ajax({
 			type : "GET",
 			url : "/checkEmailCode",
 			dataType : "json",
 			contentType : "application/json",
 			data :{code:$("#code").val(),emailCode:$("#emailCode").val()},
 			success : function(result){
 				if(result==1){
 					
 					var form =  document.getElementById("reg_form");
     				form.submit();
 				}
 				else{
//  					$("#span1").html("<font color='red'>验证码错误</font>");
 					$("#span1").html("<font color='red'>验证码错误</font>");
 				}
 			}
 	})
// 		if(code!="JTNCZFLM")
//  			{$("#span1").html("<font color='red'>验证码错误</font>");}
//  		else
//  			{var form =  document.getElementById("reg_form");
//      		form.submit();}//通过js提交表单 执行action
	}
	
	</script>
</body>
</html>